# -*- coding: utf-8 -*-
"""
Created on Fri May  8 21:46:27 2020

@author: David J Griffiths
测试摄像头功能是否正常
摄像头原始尺寸：480 * 640 
拍照界面取3:2 --> 384:256 --> 768:512
"""

import cv2
import time

cap = cv2.VideoCapture(0)
t1 = time.time()
t2 = time.time()
while (t2 - t1 < 60): #打开摄像头1分钟
    t2 = time.time()
    ret1, frame1 = cap.read()
    raw_img = frame1.copy()
    img2 = cv2.resize(raw_img,(1280,960))
    print(raw_img.shape)
    cv2.imshow('frame', img2)
    cv2.waitKey(1)
cv2.destroyAllWindows()
cap.release() #释放摄像头
print(ret1)

print(t2-t1)